<?php
namespace Admin\Controller;

/**
 * 后台首页
 *
 * @author Administrator
 *
 */
class IndexController extends CommController {

	/**
	 * 首页显示
	 */
	public function index() {
		// 获取菜单
		$menuList = D( 'UserGroup' )->menuList( $this->user['authString'] );
		$this->assign ( 'menuList', $menuList );
		// 基本配置
		$this->assign ( 'config', D ( 'Config' )->getOne ( 1 ) );
		
		// 渲染视图
		$this->display ();
	}
	
	/**
	 * 修改密码
	 */
	public function uppwd(){
		if (IS_POST) {
			if (sha1($_POST['oldpwd'])!=$this->user['password'] || $_POST['newpwd']!=$_POST['confimpwd'] || empty($_POST['newpwd'])) {
				$this->dwzSuccess( '修改失败', 0, 'Index', 'refreshThis' );
			}else{
				if(D('User')->where('id='.$this->user[id])->setField('password',sha1($_POST['newpwd']))){
					$this->dwzSuccess( '修改成功', 1, 'Index', 'refreshClose' );
				}else{
					$this->dwzSuccess( '修改失败', 0, 'Index', 'refreshClose' );
				}
			};
		}else{
			$this->display();
		}
	}
}